package pl.edu.agh.neuraleconomy.model.exchange;

import java.math.BigDecimal;
import java.util.Date;

import lombok.Data;
import lombok.EqualsAndHashCode;
import pl.edu.agh.neuraleconomy.common.utils.DateUtils;
import pl.edu.agh.neuraleconomy.model.base.BaseModel;

import com.j256.ormlite.field.DataType;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

@DatabaseTable(tableName = "exchange")
@Data
@EqualsAndHashCode(callSuper = true)
public class Exchange extends BaseModel {
	public static final String COMPANY_ID = "company_id";
	public static final String DATE = "date";
	
	@DatabaseField(canBeNull = false, foreign = true)
	private Currency currency;

	@DatabaseField(canBeNull = false, foreign = true, uniqueCombo = true, index = true, foreignAutoRefresh=true)
	private Company company;

	@DatabaseField(uniqueCombo = true, dataType = DataType.DATE)
	private Date date;
	@DatabaseField
	private BigDecimal openingPrice;
	@DatabaseField
	private BigDecimal minPrice;
	@DatabaseField
	private BigDecimal maxPrice;
	@DatabaseField
	private BigDecimal closingPrice;
	@DatabaseField
	private Integer transactions;
	@DatabaseField
	private BigDecimal turnover;
	
	public void setDate(Date date){
		this.date = DateUtils.trimDate(date);
	}
}
